Repository navigation
fix(aggregator): re-derive the price overlay at serve time for cached AA batches (#8211) - #8349
Conversation
… AA batches (#8211) aaApplyPriceOverlay separates the batch-bound payload from the batch-independent v_current_prices overlay: prices and catalog rates are recomputed from the current overlay, batch data untouched. The live source applies it to historical cache entries whose stored overlay fingerprint differs from the feed's current one, and serves priced cached batches stale-marked when no current overlay exists to refresh from.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 54 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 94ab3d41fe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| provenance.aa = `live (fleet feed · historical batch ${batch.slice(0, 8)} · collected ${parsed.section.generatedAt} · price overlay refreshed at serve)`; | ||
| return { ...aaApplyPriceOverlay(parsed.section, currentPrices), batches: batchList }; |
There was a problem hiding this comment.
Verify the latest overlay is current before replacing cached prices
When prices change without a new workbook batch or config change, this can replace freshly collected historical prices with older prices and serve them without a stale marker. In scripts/collect-fleet-feed.ts:658–675, the collector reuses lastGood.section for the latest batch without checking its price fingerprint, while historical batches are rebuilt against the new prices at lines 704–705 and marked cached. Consequently, the historical cache contains the new overlay but feed.aa.prices still contains the old one; this fingerprint mismatch then triggers a rollback of the historical prices and catalog rates. Ensure the feed overlay is validated against the collector's current-price fingerprint before treating it as authoritative.
Useful? React with 👍 / 👎.
Fixes #8211 (queue task 14715): cached historical AA batches froze the v_current_prices overlay.
Context
PR #7564 (merged after this issue was filed from its Codex review) validity-keyed the collector caches on the price overlay: on a price change the collector invalidates historical caches and rebuilds them a few per tick, and the live source stale-marks versions awaiting rebuild. What remained: a cache entry the collector still considered valid was served verbatim — batch-bound payload and frozen price snapshot together — and there was no serve-time separation of the overlay from the batch payload, so a historical batch could report old token rates as current with no marker.
Change
aaApplyPriceOverlay(section, prices)(src/aa.ts): re-derives a section's price overlay — replacespricesand recomputes every catalog entry'sratethrough the same full-id / model-part lookupaaCatalogFromConfiguses — leaving all batch-bound data (rankings, configs, thresholds, test runs, sources, cai, coverage, catalog membership) untouched and not mutating the input.pricesFingerprintdiffers from the fingerprint of the feed's current (latest-section) prices, the served section is the cached payload with the current overlay applied — same prices and catalog rates as the latest section, with no refetch of batch-bound measurements. When the feed carries no current overlay and the cached section has prices, it is servedstalewith a reason naming the price overlay, never silently. The collector-flagged awaiting-rebuild path is unchanged.Tests
bun test test/aa.test.ts test/aa-batches.test.ts— 65 pass, 0 fail:aaApplyPriceOverlay; batch-bound fields untouched, inputs unmutated; empty overlay clears prices and nulls rates like a fresh build.Note for local runs: aa.test.ts boots a server whose freshness IPC port defaults to 4871; with a standing aggregator on the laptop that collides (pre-existing, also on clean main) —
PM_AGG_FRESHNESS_PORT=<free port>avoids it.bunx tsc --noEmiterror count is unchanged from main (16, all pre-existing in test files).Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.